home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5056 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.1 KB

  1. Path: news.via.at!usenet
  2. From: helicon@helicon.co.at (helicon)
  3. Newsgroups: comp.lang.pascal.delphi.misc,comp.lang.c++
  4. Subject: Re: Delphi calls to a C++ DLL
  5. Date: 2 Feb 1996 02:46:15 GMT
  6. Organization: helicon software development
  7. Message-ID: <4erttn$l9v@newsfeed.via.at>
  8. References: <310FD68B.208B@allaire.com>
  9. NNTP-Posting-Host: helicon.via.at
  10. Mime-Version: 1.0
  11. X-Newsreader: WinVN 0.99.2
  12.  
  13. In article <310FD68B.208B@allaire.com>, jlund@allaire.com says...
  14. ;
  15. ;I have written a DLL in C++ that I am attempting to call from a Delphi EXE. I ca
  16. ;n call 
  17. ;DLL functions from my C++ apps, but not from my Delphi program. The Delphi app c
  18. ;alls the 
  19. ;DLL function, but most of the parameters passed are garbage. I tried the same te
  20. ;chniques 
  21. ;and syntax I found in the Delphi libraries, but to no avail. 
  22. ;
  23. ;For whatever reason it looks like the parameters are pushed and popped from the 
  24. ;stack 
  25. ;differently beween environments.  I've tried declaring the function in Delphi wi
  26. ;th 
  27. ;"stdcall" and "cdecl", and I've tried other data types in place of pchar. Any 
  28. ;suggestions?
  29. ;
  30. ;
  31. ;***************
  32. ;Delphi SNIPPETS
  33. ;***************
  34. ;
  35. ;{type, private}
  36. ;function GetFieldsForTable(
  37. ;   pcharDataSourceName, 
  38. ;   pcharUsername, 
  39. ;   pcharPassword, 
  40. ;   pcharTableName: pChar
  41. ;   ): integer;
  42. ;
  43. ;{implementation}
  44. ;function TODBCInformant.GetFieldsForTable; 
  45. ;   external 'patrik.dll' name 'GetFieldsForTable';
  46. ;
  47. ;{I call the function like this:}
  48. ;nIndex:= GetFieldsForTable(strpcopy(pcharBuiffer,'Test'),
  49. ;   strpcopy(pcharBuiffer,''),
  50. ;   strpcopy(pcharBuiffer,''),
  51. ;   strpcopy(pcharBuiffer,'Employees'));
  52. ;
  53. ;
  54. ;************
  55. ;C++ SNIPPETS
  56. ;************
  57. ;
  58. ;// My C++ header (.H) declares the prototype like this:
  59. ;extern "C" INT FAR PASCAL EXPORT GetFieldsForTable( 
  60. ;   LPSTR lpszDataSourceName, 
  61. ;   LPSTR lpszUsername, 
  62. ;   LPSTR lpszPassword, 
  63. ;   LPSTR lpszTableName 
  64. ;   );
  65. ;
  66. ;/* 
  67. ;My implementation uses the same format, and the function is named in the 
  68. ;exports section of the .DEF file.
  69. ;*/
  70. ;
  71.  
  72. Hi!
  73.  
  74. I think the problem is, that you use the same Buffer for each parameter. So you will get the same value 
  75. (because it's the same pointer) in each parameter.
  76.  
  77. Hope it helps :-)
  78.  
  79. Bye
  80.  
  81. Andreas
  82.  
  83.  
  84.  
  85.  
  86.